{{include file="public/header.php"/}}

<ol class="breadcrumb">
	<li>
		<span class="glyphicon glyphicon-home"></span>
		<a href="{{U('Cms/Index/welcome')}}">首页</a>
	</li>
	<li>菜单列表</li>
</ol>

<div id="page-wrapper">
<div class="row">
		<div class="col-lg-12">
			<div class="alert alert-success" style="border:solid 1px #27ae60;">
				只有三级菜单需要设置模块/控制器/方法
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-lg-12">
			<div class="main-box">
				<header class="main-box-header clearfix">
					<h2>添加菜单</h2>
				</header>
				<div class="main-box-body clearfix">
					<form role="form" onsubmit="return save();">
					<div class="form-group">
							<label for="pid">上级</label>
							<select name="pid" id="pid" class="form-control">
								<option value="0">一级菜单</option>
								{{foreach value="$v" key="$k" from="$menu"}}
									<option value="{{$v['id']}}">{{$v['_name']}}</option>
								{{/foreach}}
							</select>
						</div>
						<div class="form-group">
							<label for="title">菜单名称</label>
							<input type="text" name="title"  class="form-control" id="title">
						</div>
						<div class="form-group">
							<label for="module">模块</label>
							<input type="text" name="module"  class="form-control" id="module">
						</div>
						<div class="form-group">
							<label for="controller">控制器</label>
							<input type="text" name="controller"  class="form-control" id="controller">
						</div>
						<div class="form-group">
							<label for="action">动作</label>
							<input type="text" name="action"  class="form-control" id="action">
						</div>
						<div class="form-group">
							<label for="action">URL</label>
							<input type="text" name="url" class="form-control" id="url">
						</div>
						<div class="form-group">
							<label for="sort">排序</label>
							<input type="text" name="sort" class="form-control" id="sort" value="100">
						</div>
						
						<div class="form-group">
							<label>系统菜单</label>
							<div class="radio">
								<input type="radio" name="system" id="system1" value="1">
								<label for="system1">
									是
								</label>
							</div>
							<div class="radio">
								<input type="radio" name="system" id="system2" value="0" checked>
								<label for="system2">
									不是
								</label>
							</div>
						</div>
						<div>
							<button type="submit" class="btn btn-primary btn-xm">
								添加菜单
							</button>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>

{{include file="public/footer.php"/}}
<script>
	//删除菜单
	function save()
	{
		$.ajax({
			url:"/cms/menu",
			data:$('form').serialize(),
			type:'POST',
			dataType:'JSON',
			success:function(result)
			{
				if(result.code==0)
				{
					dialog(result.message,'success',1000,function()
					{
						location.href="/cms/menu"
					});
				}
				else
				{
					dialog(result.message,'error',1000);    
				}
			}
		})
		return false;
	}
</script>